<?php
$loader->requireOnce('includes/inPatientCore/InPatientCoreErrorCode.class.php');
$loader->requireOnce('includes/inPatientCore/InPatientCoreException.class.php');
$loader->requireOnce('includes/inPatientCore/InputServiceLoader.class.php');
$loader->requireOnce('controllers/C_InPatientSEBase.class.php');
$loader->requireOnce('includes/inPatientCore/InPatientEctomy.class.php');
$loader->requireOnce('ordo/InPatient.class.php');



/**
 * C_InSurgery Processor.
 * @package core.includes.inPatientCore
 * @author viethd
 * @version $Id$
 * @copyright 2009 LHV Company
 */
class C_InPatientEctomy extends C_InPatientSEBase  {
	private $logger ;
	private $ectomyProcessor;
	
	/**
	 *
	 * @param $controller controller for build ui
	 */
	function __construct($template_mod = "general") {
		parent::__construct($template_mod);
        $this->logger = LoggerManager::getLogger('core.controllers.C_InPatientEctomy');        
        $this->template_mod = $template_mod;
        $this->view->path="service_input";
        $this->ectomyProcessor = new InPatientEctomy($this);
		
	}	

	function actionAddEctomyAjax() {
		$result = array('error'=>array('code'=>CoreErrorCode::NORMAL,'mess'=>''), 'result'=>array());
		$ticketId = $_GET['ticketId'];
		$doctorId = $_GET['doctorId'];
		$surgeryDate = $_GET['surgeryDate'];
		$surgeryServiceId = $_GET['ectomyServiceId'];

		$this->logger->info('Start actionAddEctomyAjax');
		try {
			$this->ectomyProcessor->addEctomyService($ticketId, $surgeryServiceId,$surgeryDate, $doctorId);
		
		} catch (EnumException $ex) {
			$result['error']['code'] = $ex->getErrorCode();
            $result['error']['mess'] = InPatientCoreErrorCode::getErrorMess($ex->getErrorCode());
            $this->logger->error('Load actionAddEctomyAjax fail. Error detail: '. $ex->getMessage());
    
			
		} catch (InpatientCoreException $ex) {

			$result['error']['code'] = $ex->getErrorCode();
			$result['error']['mess'] = InPatientCoreErrorCode::getErrorMess($ex->getErrorCode());
			$this->logger->error('Load actionAddEctomyAjax fail. Error detail: '. $ex->getMessage());
		}
		$this->logger->info('Finish actionAddEctomyAjax');
		return json_encode($result);

	}
	
	function actionDeleteInPatientEctomyAjax() {
		$result = array('error'=>array('code'=>0,'mess'=>''), 'result'=>array());
        $ticketId = $_GET['ticketId'];
        $surgeryId = $_GET['surgeryId'];
        
        $this->logger->info('Start actionDeleteInPatientEctomyAjax');
        try {
            $this->ectomyProcessor->deleteInPatientEctomy($ticketId, $surgeryId);
        
        } catch (InpatientCoreException $ex) {

            $result['error']['code'] = $ex->getErrorCode();
            $result['error']['mess'] = InPatientCoreErrorCode::getErrorMess($ex->getErrorCode());
            $this->logger->error('Load actionDeleteInPatientEctomyAjax fail. Error detail: '. $ex->getMessage());
        }
        $this->logger->info('Finish actionDeleteInPatientEctomyAjax');
        return json_encode($result);
		
	}

}
?>